@include('admin::layouts.header')
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>模块配置</legend>
    </fieldset>
    <table class="layui-table" id="list" lay-filter="list"></table>
</div>
@include('admin::layouts.footer')
<script type="text/html" id="config_value">
    <input name="@{{d.key}}" data-key="@{{d.key}}" data-name="@{{d.name}}" style="width: 100%;" class="list_order layui-input" value=" @{{d.value}}" size="10"/>
</script>
<script type="text/html" id="topBtn">
	<a href="{{route('admin.modules.index')}}" class="layui-btn layui-btn-sm">返回</a>
</script>
<script>
    layui.use(['table','form'], function() {
        var table = layui.table,form = layui.form,$ = layui.jquery;
        var tableIn = table.render({
            elem: '#list',
            url: "/admin/modules/{{$key}}/edit_data",
            method:'get',
			toolbar: '#topBtn',
			title:'模块配置',
            cols: [[
                {field:'id', title: '编号',align: 'center', width:300}
                ,{field:'name', title: '备注',align: 'center', width:300}
                ,{field:'key', title: 'key',align: 'center', width:300}
                ,{field:'value', title:'value',align: 'center',width:400,templet:'#config_value'}
                
            ]],
			parseData: function(res){ //将原始数据解析成 table 组件所规定的数据
				  return res;
			}	
        });
		$('body').on('blur','.list_order',function() {
		   loading =layer.load(1, {shade: [0.1,'#fff']}); 
           var key = $(this).attr('data-key');
           var name = $(this).attr('data-name');
           var value = $(this).val();
           $.post("/admin/modules/{{$key}}/modules_update",{_method:'PUT',key:key,value:value,name:name},function(res){
                layer.close(loading);
				if (res.status == 1) {  
						layer.msg(res.msg,{time:1000,icon:1});
				}else{
				   layer.msg(res.error,{time:1000,icon:2});
					return false;
				}
           })
        });
    });
</script>
</body>
</html>